package com.example.myxm.module;

/**
 * 通用返回封装：
 *   - code: 200 表示成功，400 表示失败
 *   - message: 可选的提示信息（成功时可为空或“OK”，失败时填入具体失败原因）
 *   - data: 成功时返回的具体对象或集合，失败时可为 null
 */
public class ResultBean<T> {
    private int code;
    private String message;
    private T data;

    public ResultBean() {
    }

    public ResultBean(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }


    public ResultBean(T data) {
        this.code = 200;
        this.message = "OK";
        this.data = data;
    }


    public ResultBean(String message) {
        this.code = 400;
        this.message = message;
        this.data = null;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
